package cn.gpnusz.oliverwiki.service;

import cn.gpnusz.oliverwiki.websocket.WebSocketServer;
import org.slf4j.MDC;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author h0ss
 * @description 异步化发送websocket的业务方法 异步化只能写在外部类再去业务类调用
 * @date 2021/10/18 - 1:42
 */
@Service
public class WsService {
    @Resource
    private WebSocketServer webSocketServer;

    /**
     * 异步化发送websocket消息通知
     * @param msg : 消息内容
     * @author h0ss
     */
    @Async
    public void sendInfo(String msg, String logId) {
        MDC.put("LOG_ID", logId);
        webSocketServer.sendInfo(msg);
    }
}
